﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace Client.Test
{
    /// <summary>
    /// Interaction logic for FrmTestPrinterPanelZebra_Binding.xaml
    /// </summary>
    public partial class FrmTestPrinterPanelZebra_Binding : Window
    {
        public FrmTestPrinterPanelZebra_Binding()
        {
            InitializeComponent();
        }
    }

    public class FrmTestPrinterPanelZebra_Binding_ViewModel : BaseViewModel
    {
        public FrmTestPrinterPanelZebra_Binding_ViewModel()
        {
            initData_PrinterPanelZebra();
        }

        #region UcPrinterPanelZebra 代码示例

        void initData_PrinterPanelZebra(string configPrinterName = "")
        {
            // 可以在后台指定打印机列表只显示哪些打印机；也可以不设置控件会帮你设置
            var temp = Client.Components.PrinterPanel.PrinterUtils.GetPrinterList(isContainUpdateListItem: false) // 设置是否显示刷新选项, 这里如果采用自行赋值的方式, 建议不显示刷新选项
                .Skip(1) // 自定义打印列表 - 例如可以去掉不含有 Z 打印机
                .ToList();

            // 按照优先排序
            this.UcPrinterPanelZebra_PrinterList = Client.Components.PrinterPanel.PrinterUtils.PrinterOrderBy(temp, new List<string>() { "Fax", "OneNote for Windows 10" }, null);

            // 1. 设置选中默认打印机；也可以不设置，控件会帮你设置默认打印机。
            // this.UcPrinterPanelZebra_SelectedPrinter = this.UcPrinterPanelZebra_PrinterList.FirstOrDefault(i => i.DisplayName == Client.Components.PrinterPanel.PrinterUtils.GetDefaultPrinterName());

            // 2. 假设这是读取配置文件的打印机配置            
            configPrinterName = "Fax";
            var matchPrinter = this.UcPrinterPanelZebra_PrinterList.FirstOrDefault(i => i.DisplayName == configPrinterName);
            if (matchPrinter != null)
            {
                this.UcPrinterPanelZebra_SelectedPrinter = matchPrinter;
            }

            this.UcPrinterPanelZebra_AlignLeft = "89";
            this.UcPrinterPanelZebra_AlignTop = "85";
            this.UcPrinterPanelZebra_Darkness = "31";
            this.UcPrinterPanelZebra_Speed = "40";
        }

        private bool _UcPrinterPanelZebra_IsValidated;
        public bool UcPrinterPanelZebra_IsValidated
        {
            get { return _UcPrinterPanelZebra_IsValidated; }
            set
            {
                _UcPrinterPanelZebra_IsValidated = value;
                this.OnPropertyChanged(nameof(UcPrinterPanelZebra_IsValidated));
            }
        }


        private List<Client.Components.PrinterPanel.Printer> _UcPrinterPanelZebra_PrinterList;
        public List<Client.Components.PrinterPanel.Printer> UcPrinterPanelZebra_PrinterList
        {
            get { return _UcPrinterPanelZebra_PrinterList; }
            set
            {
                _UcPrinterPanelZebra_PrinterList = value;
                this.OnPropertyChanged("UcPrinterPanelZebra_PrinterList");
            }
        }


        private Client.Components.PrinterPanel.Printer _UcPrinterPanelZebra_SelectedPrinter;
        public Client.Components.PrinterPanel.Printer UcPrinterPanelZebra_SelectedPrinter
        {
            get { return _UcPrinterPanelZebra_SelectedPrinter; }
            set
            {
                _UcPrinterPanelZebra_SelectedPrinter = value;
                this.OnPropertyChanged("UcPrinterPanelZebra_SelectedPrinter");
            }
        }


        private string _UcPrinterPanelZebra_AlignLeft;
        public string UcPrinterPanelZebra_AlignLeft
        {
            get { return _UcPrinterPanelZebra_AlignLeft; }
            set
            {
                _UcPrinterPanelZebra_AlignLeft = value;
                this.OnPropertyChanged("UcPrinterPanelZebra_AlignLeft");
            }
        }

        private string _UcPrinterPanelZebra_AlignTop;
        public string UcPrinterPanelZebra_AlignTop
        {
            get { return _UcPrinterPanelZebra_AlignTop; }
            set
            {
                _UcPrinterPanelZebra_AlignTop = value;
                this.OnPropertyChanged("UcPrinterPanelZebra_AlignTop");
            }
        }

        private string _UcPrinterPanelZebra_Darkness;
        public string UcPrinterPanelZebra_Darkness
        {
            get { return _UcPrinterPanelZebra_Darkness; }
            set
            {
                _UcPrinterPanelZebra_Darkness = value;
                this.OnPropertyChanged("UcPrinterPanelZebra_Darkness");
            }
        }


        private string _UcPrinterPanelZebra_Speed;
        public string UcPrinterPanelZebra_Speed
        {
            get { return _UcPrinterPanelZebra_Speed; }
            set
            {
                _UcPrinterPanelZebra_Speed = value;
                this.OnPropertyChanged("UcPrinterPanelZebra_Speed");
            }
        }

        #endregion
    }
}
